package com.lh.java.util;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class TestJVMMemory {

	/**
	 * 功能描述  
	 * @Author: lh  2012-2-3 下午05:03:09
	 */
	public static void main(String[] args) {
		
		Runtime run = Runtime.getRuntime();

		long max = run.maxMemory();
		
		List<AddUserByImei> us=new ArrayList<AddUserByImei>();
		for(int i=0;i<3500;i++){
			AddUserByImei addUserByImei= new AddUserByImei();
			addUserByImei.setId(5);
			addUserByImei.setImei("sa1234567890asd");
			addUserByImei.setRecordTime(new Date());
			us.add(addUserByImei);
		}
		
		long total = run.totalMemory();
		long free = run.freeMemory();

		long usable = max - total + free;

		System.out.println("M最大内存 = " + max/(1024*1024));
		System.out.println("已分配内存 = " + total/(1024*1024));
		System.out.println("已分配内存中的剩余空间 = " + free/(1024*1024));
		System.out.println("最大可用内存 = " + usable/(1024*1024)); 
	}

}
